<template>
  <div>
    <el-card style="margin-top: 5px">
      <el-form ref="form" :model="formData" label-width="80px">
        <el-row>
          <el-col :span="18">
            <el-form-item label="监督机构" prop="orgId" style="margin-left: 50px;margin-top: 20px">
              <el-select v-model="formData.orgId" clearable style="margin-left: 20px;" placeholder="请选择">
                <el-option
                  v-for="item in orglist"
                  :key="item.id"
                  :label="item.orgName"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6" style="margin-top: 20px">
            <el-col :span="2" style="margin-left: 5px">
              <el-button type="success" @click="$router.go()" >返回</el-button>
            </el-col>
            <el-col :span="2" style="margin-left: 50px">
              <el-button type="success" @click="quire" icon="el-icon-search">检索</el-button>
            </el-col>
            <el-col :span="2" style="margin-left: 100px">
              <download-excel
                class="export-excel-wrapper"
                :data="personlist"
                :fields="fields"
                :header="title"
                name="专业技术人员基本情况表.xls">
                <el-button type="warning" icon="el-icon-download" >导出</el-button>
              </download-excel>
            </el-col>
          </el-col>
        </el-row>
      </el-form>
      <p style="margin-top: 50px"></p>
      <el-table
        :data="personlist"
        border style="width:100%;">
        <el-table-column
          prop="ge"
          label="项目"
          width="160">
        </el-table-column>
        <el-table-column>
          <el-table-column label="合计" prop="num" width="70"></el-table-column>
          <el-table-column label="女" prop="women" width="70"></el-table-column>
          <el-table-column label="少数民族" prop="mini" width="70"></el-table-column>
          <el-table-column label="中国党员" prop="pols" width="70"></el-table-column>
        </el-table-column>
        <el-table-column  label="学历" width="20">
          <el-table-column label="博士" prop="doctor" width="70">
          </el-table-column>
          <el-table-column label="研究生" prop="Master" width="70">
          </el-table-column>
          <el-table-column label="大学本科" prop="undergraduate" width="70">
          </el-table-column>
          <el-table-column label="大学专科" prop="college" width="70">
          </el-table-column>
          <el-table-column label="中专" prop="special" width="70">
          </el-table-column>
          <el-table-column label="高中及以下" prop="st" width="50">
          </el-table-column>
        </el-table-column>
        <el-table-column  label="年龄" width="70">
          <el-table-column label="35岁以下" width="70" prop="agea">
          </el-table-column>
          <el-table-column label="36岁到40岁" width="70" prop="ageb">
          </el-table-column>
          <el-table-column label="41岁到45岁" width="70" prop="agec">
          </el-table-column>
          <el-table-column label="46岁到50岁" width="70" prop="aged">
          </el-table-column>
          <el-table-column label="51岁到54岁" width="70" prop="agee">
          </el-table-column>
          <el-table-column label="55岁及以上" width="70" prop="agef">
          </el-table-column>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
  import {post} from "@/utils/api";
  export default {
    data() {
      return {
        formData:{},
        orglist:[],
        personlist:[],
        list:[],
        ids:[],
        title:"专业技术人员基本情况表",
        fields:{'项目':'ge','合计':'num','女':'women','少数民族':'mini','中共党员':'pols','博士':'doctor','研究生':'Master','大学本科':'undergraduate','大学专科':'college','中专':'special','高中及以下':'st','35岁及以下':'agea','36岁到40岁':'ageb','41岁到45岁':'agec','46岁到50岁':'aged','51岁到54岁':'agee','55岁及以上':'agef'}
      }
    },
    async created() {
      let res = await post("org/getallorg")
      this.orglist = res
      let res1 = await post("person/getallorgid")
      this.ids = res1.map((item,index)=>{
        return item.orgId
      })
      console.log(this.ids)
      this.getbypage()
    },
    methods: {
      async getbypage() {
        let res1 = await post("person/get6", {id: this.ids})
        let res2 = await post("person/get7", {id: this.ids})
        let res3 = await post("person/get8", {id: this.ids})
        let res4 = await post("person/get9", {id: this.ids})
        let res5 = await post("person/get10", {id: this.ids})
        let res6 = await post("person/get11", {id: this.ids})
        let res7 = await post("person/get12", {id: this.ids})
        this.personlist = res1.map((item, index) => {
          return {...item, ...res2[index], ...res3[index], ...res4[index], ...res5[index],...res6[index],...res7[index]}
        })
        this.list = res1.map((item,index)=>{
          return {...item,...res2[index],...res3[index],...res4[index],...res5[index],...res6[index],...res7[index]}
        })
        this.personlist = this.list.map(item=>{
          if(item.ge == 'ta')
            item.ge = '初级';
          if(item.ge=='tb')
            item.ge = '中级';
          if(item.ge =='tc')
            item.ge = '副高级';
          if(item.ge=='td')
            item.ge = '正高级';
          if(item.ge =='te')
            item.ge = '未聘任专业技术职称';
          return item
        })
        console.log(this.personlist);
      },
      async quire() {
        console.log(this.formData.orgId)
        // this.ids=[]
        this.ids = this.formData.orgId
        let res1 = await post("person/get6", {id: this.ids})
        let res2 = await post("person/get7", {id: this.ids})
        let res3 = await post("person/get8", {id: this.ids})
        let res4 = await post("person/get9", {id: this.ids})
        let res5 = await post("person/get10", {id: this.ids})
        let res6 = await post("person/get11", {id: this.ids})
        let res7 = await post("person/get12", {id: this.ids})
        this.list = res1.map((item,index)=>{
          return {...item,...res2[index],...res3[index],...res4[index],...res5[index],...res6[index],...res7[index]}
        })
        this.personlist = this.list.map(item=>{
          if(item.ge == 'ta')
            item.ge = '初级';
          if(item.ge=='tb')
            item.ge = '中级';
          if(item.ge =='tc')
            item.ge = '副高级';
          if(item.ge=='td')
            item.ge = '正高级';
          if(item.ge =='te')
            item.ge = '未聘任专业技术职称';
          return item
        })
        console.log(this.personlist)
      },

    }
  }
</script>
<style></style>
